<?php

$ip = $_SERVER['REMOTE_ADDR'];
$opr = !isset($_GET["opr"]) ? 'home' : anti_injection($_GET["opr"]);
$halaman = !isset($_GET["halaman"]) ? 0 : anti_injection($_GET["halaman"]);
$offset = 12;




// home
//if ($opr == 'home' or isset($opr)) {
if ($opr == 'home') {
    get_produk_list(null, null, $offset);
}

// kategori
elseif ($opr == 'kategori') {
    $kategori = !isset($_GET["id"]) ? NULL : anti_injection($_GET["id"]);
    $id = get_kategori_id_from_seo($kategori);
    get_produk_list($id, $halaman, $offset);
}

// profile
elseif ($opr == 'info') {
    $id = '1';
    get_statik_from_id($id);
}

// cara-beli
elseif ($opr == 'cara-beli') {
    $id = '2';
    get_statik_from_id($id);
}

// hubungi-kami
elseif ($opr == 'hubungi-kami') {
    //get_contact();
    $id = '3';
    get_statik_from_id($id);
}

// cek-transaksi
elseif ($opr == 'cek-transaksi') {
    //echo "cek-transaksi";
    $kode = !isset($_GET["kode"]) ? '' : anti_injection($_GET["kode"]);
    echo "\n <div id=\"ki_detail\">";
    echo "<div class=\"kode\">";
    echo " <form method=\"get\" action=\"" . URLPUBLICINDEX . "\">";
    echo "  <input type=\"hidden\" name=\"opr\" value=\"cek-transaksi\" />";
    echo "  <input type=\"text\" id=\"kode\" maxlength=\"7\"  name=\"kode\" value=\"" . $kode . "\"  placeholder=\"Kode Transaksi\"/>";
    echo "  <input type=\"submit\" value=\"Cari\" />";
    echo " </form>";
    get_kode_transaksi($kode);
    echo "</div>";
    echo "\n </div>";
}


// produk
elseif ($opr == 'produk') {
    get_produk_list(null, $halaman, $offset);
}

// detail
elseif ($opr == 'detail') {
    $produk = !isset($_GET["id"]) ? NULL : anti_injection($_GET["id"]);
    $id = get_produk_id_from_seo($produk);
    get_produk_detail($id);

    /*
      echo '    <div id="disqus_thread"></div>
      <script type="text/javascript">
      var disqus_shortname = \'rider-adem-bener\'; // required: replace example with your forum shortname

      (function() {
      var dsq = document.createElement(\'script\'); dsq.type = \'text/javascript\'; dsq.async = true;
      dsq.src = \'//\' + disqus_shortname + \'.disqus.com/embed.js\';
      (document.getElementsByTagName(\'head\')[0] || document.getElementsByTagName(\'body\')[0]).appendChild(dsq);
      })();
      </script>';
     */
}

// produk
elseif ($opr == 'cari') {
    $kata = !isset($_GET["c"]) ? '' : htmlentities($_GET["c"]);
    get_produk_cari($kata, $halaman, $offset);
}

// tidak semua
else {
    lempar_ke_home();
    //echo '<meta http-equiv="Refresh" content="1;url=' . URLPUBLICINDEX . '?opr=home">';
}
?>
